require_relative './inter'
require_relative './eval'


l = Stone::Lex.new(file = File.open("./example", "r"))
p = Stone::StoneParser.new
e = Stone::NestedEnv.new(nil)

require 'optparse'

options = { }
OptionParser.new do |opts|
  opts.banner = "STONE"

  opts.on "-f FILE", "--file FILE" do |f|
    puts f
    l = Stone::Lex.new(file=File.open(f, "r"))
  end

  opts.on "-r", "--run" do 
    Stone::BasicInterpreter.new(l, p, e).run
  end

  opts.on "-v", "--verbose" do |v|
    options[:v] = v
  end

  opts.on "-p", "--parse" do 
    while l.peek != Stone::Lex::EOF
      ast = p.parse(l)
      puts ast
      pp ast if options[:v]
    end
  end
end.parse!

file.close
